package com.huike.web.controller.report;


import com.huike.contract.domain.vo.IndexBusinessChangeStatisticsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.ReportService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private ReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    @GetMapping
    public AjaxResult getTodayInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                   @RequestParam("endCreateTime") String endCreateTime){
        Map map = reportService.selectInfo(beginCreateTime,endCreateTime);
        return AjaxResult.success(map);
    }

    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                               @RequestParam("endCreateTime") String endCreateTime) {
        List<IndexBusinessChangeStatisticsVO> list = reportService.businessChangeStatistics(beginCreateTime, endCreateTime);
        return AjaxResult.success(list);
    }

    /**
     * 首页线索转化龙虎榜
     *
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(@RequestParam("beginCreateTime") String beginCreateTime,
                                     @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.salesStatistic(beginCreateTime,endCreateTime));
    }
}